package org.com.app.knock.fragment;

import java.util.HashMap;

import z.lib.base.BaseServiceCallBack;
import z.lib.base.BaseUtils;
import z.lib.base.BaseUtils.API;
import z.lib.base.CommonAndroid;
import z.lib.base.LogUtils;
import z.lib.base.callback.RestClient.RequestMethod;
import android.annotation.SuppressLint;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageButton;

import com.knock.app.R;

/**
 * Created by paveld on 4/17/14.
 */
@SuppressLint("NewApi")
public class F1Fragment extends Fragment implements OnClickListener{
	private static final String LIST_FRAGMENT_TAG = "list_fragment";
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        return inflater.inflate(R.layout.row, container, false);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        HashMap<String, String> inputs = new HashMap<String, String>();
		// params.put("req[lang]", "ja");
		inputs.put("req[param][user_id]", "123141210E");
		inputs.put("req[param][password]", "1234567a");
		BaseUtils.execute(getActivity(), RequestMethod.GET, API.API_USER_LOGIN, inputs, callback);
		ImageButton btnHome2 = (ImageButton) view.findViewById(R.id.close);
		btnHome2.setOnClickListener(this);
    }
    
    @Override
	public void onClick(View v) {
		int idView = v.getId();
		LogUtils.e("kkkkkkkkkk","kkkkkkk1");
		switch (idView) {
		case R.id.close:
			Fragment f = getActivity().getFragmentManager().findFragmentByTag(LIST_FRAGMENT_TAG);
	        if (f != null) {
	            getFragmentManager().popBackStack();
	        }
	        LogUtils.e("kkkkkkkkkk","kkkkkkk");
			break;

		default:
			break;
		}
	}
    
	private BaseServiceCallBack callback = new BaseServiceCallBack() {

		public void onStart() {
			CommonAndroid.hiddenKeyBoard(getActivity());
//			CommonAndroid.showView(true, getView().findViewById(R.id.progressbar));
		};

		public void onError(String message) {
//			if (!isFinish()) {
//				BaseUtils.showDialog(getActivity(), "" + message);
//				CommonAndroid.showView(false, getView().findViewById(R.id.progressbar));
//				startAnimation();
//			}
		};

		public void onSucces(String response) {
			LogUtils.e("aaaa", response.toString());
//			if (!isFinish()) {
//				CommonAndroid.showView(false, getView().findViewById(R.id.progressbar));
//				startActivity(new Intent(getActivity(), SkyMainActivity.class));
//				finish();
//			}
		};
	};
}
